#replace import tensorflow as tf by following
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
change the <tf.placeholder> as <tf.compat.v1.placeholder>
such as
x = tf.placeholder(shape = [None, image_pixels], dtype = tf.float32)
change as
x = tf.compat.v1.placeholder(shape = [None, image_pixels], dtype = tf.float32)
but there would be another problem about runtime error with eager execution add <tf.compat.v1.disable_eager_execution()> after import part
import tensorflow as tf
tf.compat.v1.disable_eager_execution()